package com.panshi.controller;

import com.panshi.api.IQuestionApi;
import com.panshi.api.IQuestionAuditApi;
import com.panshi.api.IReplyApi;
import com.panshi.api.IReplyAuditApi;
import com.panshi.vo.DataResult;
import com.panshi.vo.qa.*;
import feign.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
public class QuestionController {

    @Autowired//问题未审核
    private IQuestionAuditApi questionAuditApi;

    @Autowired//已审核
    private IQuestionApi questionApi;

    @Autowired//回答未审核
    private IReplyAuditApi replyAuditApi;

    @Autowired//已审核
    private IReplyApi replyApi;

    @GetMapping("/sys-q/findQ")
    public DataResult findUncheckQ(@Param("page") Integer page, @Param("limit") int limit){
        Pages p = new Pages();
        p.setStartPage(page);
        p.setPageSize(limit);
        p.setState(1);
        DataResultQA<Pages<QuestionAudit>> dataResultQA = questionAuditApi.inquirePagesQuestionAudit(p);
        DataResult data = new DataResult();
        data.setData(dataResultQA.getData());
        data.setMsg(dataResultQA.getDescribe());
        return data;
    }

    @GetMapping("/sys-q/findCheck")
    public DataResult findCheckQ(@Param("page") Integer page, @Param("limit") int limit){
        Pages p = new Pages();
        p.setStartPage(page);
        p.setPageSize(limit);
        p.setState(1);
        DataResultQA<Pages<Question>> dataResultQA = questionApi.inquirePagesQuestion(p);
        DataResult data = new DataResult();
        data.setData(dataResultQA.getData());
        data.setMsg(dataResultQA.getDescribe());
        return data;
    }
//inquirePagesReply

    @GetMapping("/sys-a/findA")
    @ResponseBody
    public DataResult findCheckA(@Param("page") Integer page, @Param("limit") int limit){
        Pages p = new Pages();
        p.setStartPage(page);
        p.setPageSize(limit);
        p.setState(1);
        DataResultQA<Pages<ReplyAudit>> dataResultQA = replyAuditApi.inquireReplyAuditPages(p);
        DataResult data = new DataResult();
        data.setData(dataResultQA.getData());
        data.setMsg(dataResultQA.getDescribe());
        return data;
    }

    @GetMapping("/sys-a/findCheck")
    public DataResult findUncheckA(@Param("page") Integer page, @Param("limit") int limit){
        Pages p = new Pages();
        p.setStartPage(page);
        p.setPageSize(limit);
        p.setState(1);
        DataResultQA<Pages<Reply>> dataResultQA = replyApi.inquirePagesReply(p);
        DataResult data = new DataResult();
        data.setData(dataResultQA.getData());
        data.setMsg(dataResultQA.getDescribe());
        return data;
    }
}


